package settings_api

import (
	"gin_study_blog/common"
	"gin_study_blog/common/http"
	"github.com/gin-gonic/gin"
)

type SettingUri struct {
	Name string `uri:"name"`
}

// SettingsApiView 配置信息
func (SettingsApi) SettingsApiView(c *gin.Context) {
	var uri SettingUri
	err := c.ShouldBindUri(&uri)
	if err != nil {
		http.FailWithCode(http.ParamsError, c)
		return
	}
	switch uri.Name {
	case "site":
		http.IsOkWithData(common.Config.SiteInfo, c)
	case "email":
		http.IsOkWithData(common.Config.Email, c)
	case "qq":
		http.IsOkWithData(common.Config.QQ, c)
	case "qiniu":
		http.IsOkWithData(common.Config.QiNiu, c)
	case "jwt":
		http.IsOkWithData(common.Config.Jwt, c)
	default:
		http.FailWithMessage("不存在对应的配置文件", c)
	}
}
